#ifndef  __WF_PIDCONTROL_H__
#define  __WF_PIDCONTROL_H__

#ifdef   WF_PIDCONTROL_GLOBALS
#define  WF_PIDCONTROL_EXT
#else
#define  WF_PIDCONTROL_EXT  extern
#endif

typedef struct
{
   MotorAction Action;
   uint8_t Runing;
   float RunTime;//最低0.1 单位s
}MotorSetTime_ST;

typedef enum
{
    BothMotorSetArg_ENUM_Type_LLimt,
    BothMotorSetArg_ENUM_Type_RTime,
}BothMotorSetArg_ENUM_Type;

typedef struct 
{
    BothMotorSetArg_ENUM_Type type;//0低限位 1运行指定时间
    uint8_t ShareInOrderSta_x;
    MOTORTYPE motor1;
    MOTORTYPE motor2;
    MotorAction Action;
    uint32_t *enter_state_tick;
    float TimeOut;
    uint8_t RawAlarm_DI1_LLimit;
    uint8_t RawAlarm_DI2_LLimit;
    uint8_t RawAlarm_DI1_HLimit;
    uint8_t RawAlarm_DI2_HLimit;
    uint8_t RawAlarm_MAC_Fail;//超时告警
}BothMotorRunArg_ST;

typedef struct 
{
    uint8_t ShareInOrderSta_x;
    MOTORTYPE motor1;
    MOTORTYPE motor2;
    uint32_t *enter_state_tick;
    float TimeOut;
    uint8_t RawAlarm_MAC_Fail;//超时告警
    uint8_t RawAlarm_MAC_LLimit;//调节到最小限位
    uint8_t RawAlarm_MAC_HLimit;//调节到最大限位
    float SetVal;
    float *ComputeSource;
    uint8_t RawAlarm_DI1_LLimit;
    uint8_t RawAlarm_DI2_LLimit;
    uint8_t RawAlarm_DI1_HLimit;
    uint8_t RawAlarm_DI2_HLimit;
}BothMotorSetValArg_ST;

typedef enum
{
    PriMover_ENUM_Type_Stop,
    PriMover_ENUM_Type_Start,
}PriMover_ENUM_Type;

typedef struct 
{
    PriMover_ENUM_Type type;
    uint32_t *enter_state_tick;
    uint16_t SetFre;//设置频率
    float SetTime;//加减速时间
    float TimeOut;//超时时间 s
    uint8_t ShareInOrderSta_x;
    uint8_t RawAlarm_MAC_Fail;//超时告警
}PriMover_ST;




typedef struct
{
    PriMover_ENUM_Type type;//0停止 1启动 2 设置频率
    uint16_t SetFre;//设置频率
    float SetTime;//加减速时间
    float TimeOut;//超时时间 s
}PRIMOVERCONFIG;

typedef struct
{
    float SetVal; 
    float TimeOut;//超时时间 s
}MotorSetVal_ST;

typedef struct
{
    float TimeOut;//超时时间 s
}MotorLimVal_ST;

WF_PIDCONTROL_EXT uint64_t SysTickCount;//5ms计数一次

WF_PIDCONTROL_EXT BothMotorRunArg_ST BothMotorSetArg_st;
WF_PIDCONTROL_EXT MotorLimVal_ST BVolLimVal_st;
WF_PIDCONTROL_EXT MotorSetTime_ST BVolSetTime_st;
WF_PIDCONTROL_EXT MotorSetVal_ST BVolSetVal_st;

WF_PIDCONTROL_EXT MotorLimVal_ST ExcvLimVal_st;
WF_PIDCONTROL_EXT MotorSetTime_ST ExcvSetTime_st;
WF_PIDCONTROL_EXT MotorSetVal_ST ExcvSetVal_st;

WF_PIDCONTROL_EXT MotorLimVal_ST ExciLimVal_st;
WF_PIDCONTROL_EXT MotorSetTime_ST ExciSetTime_st;
WF_PIDCONTROL_EXT MotorSetVal_ST ExciSetVal_st;

WF_PIDCONTROL_EXT PRIMOVERCONFIG PriMoverConfig;
uint8_t PIDControlRequestWorkLayerHandle(uint8_t TempWorkflow, uint8_t *ActInform);
uint8_t PidReqBVolLimVal(float TimeOut);
uint8_t PidReqBVolSetVal(float SetVal,float TimeOut);
uint8_t PidReqBVolSetTime(MotorAction Action,float RunTime);
uint8_t PidReqExcvLimVal(float TimeOut);
uint8_t PidReqExcvSetVal(float SetVal,float TimeOut);
uint8_t PidReqExcvSetTime(MotorAction Action,float RunTime);
uint8_t PidReqExciLimVal(float TimeOut);
uint8_t PidReqExciSetVal(float SetVal,float TimeOut);
uint8_t PidReqExciSetTime(MotorAction Action,float RunTime);
uint8_t PidReqPriMoverStartStop(uint16_t SetFre,float SetTime,PriMover_ENUM_Type type,float TimeOut,uint8_t ShareInOrderSta_x);
#endif